package com.pactera.madp.cp.service.sync.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pactera.madp.cp.api.entity.sync.MaTotalDataBoardEntity;
import com.pactera.madp.cp.mapper.sync.MaTotalDataBoardMapper;
import com.pactera.madp.cp.service.sync.MaTotalDataBoardService;
import org.springframework.stereotype.Service;

/**
 * @author Deming.Chang
 * @title 经理视图 -> 数据看板汇总 业务接口实现
 * @date 2022-05-26
 */
@Service
public class MaTotalDataBoardServiceImpl extends ServiceImpl<MaTotalDataBoardMapper, MaTotalDataBoardEntity> implements MaTotalDataBoardService {

    @Override
    public Long visitor(String wxUserId) {
        MaTotalDataBoardEntity entity = this.getOne(
                Wrappers.<MaTotalDataBoardEntity>lambdaQuery()
                        .eq(MaTotalDataBoardEntity::getRecommendId, wxUserId), false
        );
        if (entity != null) {
            return entity.getTotalVisitors();
        } else {
            return 0L;
        }
    }

}
